#include <stdio.h>
#include <stdlib.h>


void printfMatrix(char** p, int row, int col)
{
    int i = 0, j = 0;
    for(i = 0; i < row ; i++)
    {
        for(j = 0; j < col; j++)
        {
            printf("%c(%d %d)\t", p[i][j], i, j);
        }
        printf("\r\n");
    }
}

int partition(int ints[], int left, int right)
{
    int pivot = ints[left];

    while(left < right)
    {
        while(left < right && ints[right] >= pivot)
            right--;
        if(left < right)
            ints[left++] = ints[right];
        while(left < right && ints[left] <= pivot)
            left++;
        if(left < right)
            ints[right--] = ints[left];
    }
    ints[left] = pivot;
    return left;
}

void qicksort(int ints[], int left, int right)
{
    int pivotpos = 0;
    if(left < right)
    {
        pivotpos = partition(ints, left, right);
        qicksort(ints, left, pivotpos - 1);
        qicksort(ints, pivotpos + 1, right);
    }

}

int getmax(char** p, int xi, int yi, int row, int col)
{
    int ncount = 0;
    int xxi = xi, yyi = yi;

    for(xxi = xi - 1, yyi = yi; xxi >=0 && xxi < row && p[xxi][yyi] != '.'; xxi--)
        ncount++;
    for(xxi = xi + 1, yyi = yi; xxi >=0 && xxi < row && p[xxi][yyi] != '.'; xxi++)
        ncount++;
    for(xxi = xi, yyi = yi - 1; yyi >=0 && yyi < col && p[xxi][yyi] != '.'; yyi--)
        ncount++;
    for(xxi = xi, yyi = yi + 1; yyi >=0 && yyi < col && p[xxi][yyi] != '.'; yyi++)
        ncount++;

    return ncount;
}

//
int compareMatrixs(char** pl, char** pr, int row, int col, int n)
{
    int *ql = NULL, *qr = NULL;
    int i = 0, j = 0;
    int flag = 0;


    ql = (int*)malloc(n * sizeof(int));
    qr = (int*)malloc(n * sizeof(int));

    for(i = 0; i < row; i++)
    {
        for(j = 0; j < col; j++)
        {
            if(pl[i][j] != '.')
            {
                ql[pl[i][j] - 'A'] = getmax(pl, i, j, row, col);
            }
            if(pr[i][j] != '.')
            {
                qr[pr[i][j] - 'A'] = getmax(pr, i, j, row, col);
            }
        }
    }

    qicksort(ql, 0, n-1);
    qicksort(qr, 0, n-1);

    for(i = 0; i < n; i++)
    {
        if(ql[i] != qr[i])
        {
            flag = 1;
            break;
        }

    }

    free(ql);
    free(qr);

    return flag;
}

int main()
{
    char **matrix1 = NULL, **matrix2 = NULL;
    int ndata = 0;
    int *presult = NULL;
    int w = 0, h = 0, n = 0, xi = 0, yi = 0;
    int i = 0, j = 0, k = 0;

   // freopen("bin\\debug\\in.txt", "r", stdin);
    scanf("%d", &ndata);
    presult = (int*)malloc(ndata * sizeof(int));
    for(k = 0; k < ndata; k++)
    {


        scanf("%d %d %d", &w, &h, &n);

        matrix1 = (char**)malloc(w * sizeof(int*));
        matrix2 = (char**)malloc(w * sizeof(int*));
        if(matrix1 == NULL || matrix2 == NULL)
            exit(-1);

        for(i = 0; i < w; i++)
        {
            matrix1[i] = (char*)malloc(h * sizeof(char));
            for(j = 0; j < h; j++)
                matrix1[i][j] = '.';
            matrix2[i] = (char*)malloc(h * sizeof(char));
            for(j = 0; j < h; j++)
                matrix2[i][j] = '.';
        }


        for(i = 0; i < n; i++)
        {
            scanf("%d %d", &xi, &yi);
            matrix1[xi][yi] = 'A' + i;
        }
        for(i = 0; i < n; i++)
        {
            scanf("%d %d", &xi, &yi);
            matrix2[xi][yi] = 'A' + i;
        }

        presult[k] = compareMatrixs(matrix1, matrix2, w, h, n);

    }

    for(k = 0; k < ndata; k++)
    {
        printf("%s\r\n",presult[k] == 1 ? "NO" : "YES");
    }
    return 0;
}
